package cn.cnhis.online.mymodule.sp;

import android.content.Context;

import com.google.gson.Gson;

import cn.cnhis.online.activity.login.view.LoginActivity;
import cn.cnhis.online.mymodule.Constants;
import cn.cnhis.online.mymodule.Utils.SPUtils;
import cn.cnhis.online.mymodule.bean.LoginBean;

/**
 * Created by wuzhc on 2018/9/11.
 */

public class MySpUtils {
    /**
     * 保存在手机里面的文件名 - 临时文件
     */
    public static final String USER_FILE = "USER_FILE";
    public static final String USERINFO = "USERINFO";
    public static final String LOCATIONINFO = "LOCATIONINFO";
    public static final String ADDRESSINFO = "ADDRESSINFO";
    public static final String ISLOGIN = "ISLOGIN";


    public static void setThemeColor(Context mContext, String string) {
        SPUtils.put(mContext, Constants.THEME_COLOR_INFO, string);
    }

    public static String getThemeColor(Context mContext) {
        return (String) SPUtils.get(mContext, Constants.THEME_COLOR_INFO, "");
    }

    public static void setNetWorkAddress(Context mContext, String string) {
        SPUtils.put(mContext, ADDRESSINFO, string);
    }

    public static String getNetWorkAddress(Context mContext) {
        return (String) SPUtils.get(mContext, ADDRESSINFO, "");
    }

    public static void setUserInfo(Context mContext, String string) {
        SPUtils.put(mContext, USERINFO, string);
    }

    public static String getUseInfo(Context mContext) {
        return (String) SPUtils.get(mContext, USERINFO, "");
    }

    public static void setLocationInfo(Context mContext, String string) {
        SPUtils.put(mContext, LOCATIONINFO, string);
    }

    public static String getLocationInfo(Context mContext) {
        return (String) SPUtils.get(mContext, LOCATIONINFO, "");
    }

    public static void clear(Context mContext) {
        SPUtils.clear(mContext);
    }

    public static void clearTemp(Context mContext) {
        SPUtils.clear(mContext, USER_FILE);
    }

    public static String getMQINFO(Context mContext) {
        return (String) SPUtils.get(mContext, Constants.MQ_INFO, "");
    }

    public static void setMQINFO(Context mContext, String info) {
        SPUtils.put(mContext, Constants.MQ_INFO, info);
    }

    public static void setLoginErrorCount(Context context, int loginCount) {
        SPUtils.put(context, Constants.LOGIN_ERROR_COUNT, loginCount);
    }

    public static Integer getLoginErrorCount(Context context) {
        return (Integer) SPUtils.get(context, Constants.LOGIN_ERROR_COUNT, new Integer(0));
    }

    public static void setSysLoginSessionId(Context context, String sysLoginSessionId) {
        SPUtils.put(context, Constants.SYS_LOGIN_SESSIONID, sysLoginSessionId);
    }

    public static String getSysLoginSessionId(Context context) {
        return (String) SPUtils.get(context, Constants.SYS_LOGIN_SESSIONID, "");
    }

    public static void setLoginStatus(Context context, boolean isLogin) {
        SPUtils.put(context, Constants.IS_LOGIN, isLogin);
    }

    public static boolean getLoginStatus(Context context) {
        return (boolean) SPUtils.get(context, Constants.IS_LOGIN, false);
    }

    public static void setAgreementStatus(Context context,boolean status) {
        SPUtils.put(context, Constants.READ_AGREEMENT, status);
    }

    public static boolean getAgreementStatus(Context context) {
        return (boolean) SPUtils.get(context, Constants.READ_AGREEMENT, false);
    }
}
